<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property int $room_id 群ID
 * @property array $content 推送内容
 * @property int $unassigned_strategy 未分配策略：0=尝试发送 1=跳过发送 2=随机分配号
 * @property int $status 0=发送中 1=发送成功 2=发送失败
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class ChRoomPushMsg extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_room_push_msg';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'room_id', 'content', 'unassigned_strategy', 'status', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'room_id' => 'integer', 'content' => 'array', 'unassigned_strategy' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function room(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRoom::class, 'id', 'room_id');
    }

    public function robots(): \Hyperf\Database\Model\Relations\BelongsToMany
    {
        return $this->belongsToMany(ChRobot::class, 'ch_room_push_msg_robot', 'push_id', 'robot_id');
    }
}
